//
//  YQNewWalletAddressVC.m
//  NewRetail
//
//  Created by yuqin on 2019/6/23.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQNewWalletAddressVC.h"
#import "YQNewWalletAddressCell.h"
#import "YQAddressBottomView.h"

@interface YQNewWalletAddressVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *addressTableView;
@property (nonatomic, strong) YQAddressBottomView *bottomView;

@end

@implementation YQNewWalletAddressVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.txtTitle.text = @"新建钱包";
    [self setupAddressView];
}

- (void)setupAddressView {
    [self.view addSubview:self.addressTableView];
    [self.view addSubview:self.bottomView];
    [self.addressTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(NavigationStatusBarHeight+FIT(36));
        make.left.mas_equalTo(FIT(18));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(36), ScreenHeight-NavigationStatusBarHeight-FIT(135)));
    }];
    
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-(Botoom_IPhoneX+FIT(20)));
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(FIT(135));
    }];
    
}

- (UITableView *)addressTableView {
    if (!_addressTableView) {
        _addressTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _addressTableView.backgroundColor = [UIColor clearColor];
        _addressTableView.delegate = self;
        _addressTableView.dataSource = self;
        [_addressTableView  setSeparatorStyle:UITableViewCellSeparatorStyleNone];
        
        [_addressTableView registerClass:[YQNewWalletAddressCell class] forCellReuseIdentifier:YQ_NewWalletAddressCell];
    }
    return _addressTableView;
}

- (YQAddressBottomView *)bottomView {
    if (!_bottomView) {
        _bottomView = [[YQAddressBottomView alloc] init];
        //各种点击事件
    }
    return _bottomView;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return FIT(52);
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return 0;
    }else {
        return FIT(36);
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.0001;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQNewWalletAddressCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_NewWalletAddressCell forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    NSDictionary *placeDict = @{@"1":@"给自己的钱包取个名字，如：数字钱包",
                                @"2":@"邀请人钱包地址",
                                @"3":@"设置密码，保护私钥和交易授权",
                                @"4":@"请再次确认密码"
                                };
    cell.addressTF.placeholder = [placeDict objectForKey:StringFromLongInt(indexPath.section+1)];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return nil;
}

@end
